<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            background-color: #f00;
            position: relative;
        }

        .box img {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;

            max-width: 90%;
            max-height: 90%;
        }
    </style>
</head>

<body>

    <div class="box">
        <img src="https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics1.baidu.com%2Ffeed%2F83025aafa40f4bfb03d4e3246ef43dfbf6361884.jpeg%40f_auto%3Ftoken%3De49ac45529fbbc6ec4372964fe34a630&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1668877200&t=1316310965351b4cf42b398e5be184cf"
            alt="">
    </div>

</body>

</html>